﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HZ.Supervise.Web.Meet
{
    public partial class CHRYList_zx : BasePage
    {
        IBLL.IBLL_ProcureCatalog ihc = new HZ.Supervise.BLL.BLL_ProcureCatalog();
        public string mid = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["mid"] == null)
            {
                Response.Redirect("MeetList_zx.aspx");
            }
            if (!IsPostBack)
            {
                BindList();
            }
            mid = Request["mid"].ToString();
        }

        private void BindList()
        {
            int totalCount = 0;
            string str = "and MID='" + Request["mid"].ToString() + "'";
            if (!string.IsNullOrEmpty(ddlshizhou.SelectedValue))
            {
                str += string.Format(" and CHAreaID='{0}'", ddlshizhou.SelectedValue);
            }
            if (!string.IsNullOrEmpty(txtHName.Text.Trim()))
            {
                str += string.Format(" and HosName like '%{0}%'", txtHName.Text.Trim());
            }
            DataTable dt = ihc.GetMeetInfoListzbzx(str, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
            AspNetPager1.RecordCount = totalCount;
            gvw.PageSize = AspNetPager1.PageSize;
            gvw.DataSource = dt;
            gvw.DataBind();
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
        }

        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            BindList();
        }

        protected void btnexcel_Click(object sender, EventArgs e)
        {
            int totalCount = 0;
            string str = "and MID='" + Request["mid"].ToString() + "'";
            if (!string.IsNullOrEmpty(ddlshizhou.SelectedValue))
            {
                str += string.Format(" and CHAreaID='{0}'", ddlshizhou.SelectedValue);
            }
            if (!string.IsNullOrEmpty(txtHName.Text.Trim()))
            {
                str += string.Format(" and HosName like '%{0}%'", txtHName.Text.Trim());
            }
            DataTable dt = ihc.GetMeetInfoListzbzx(str, 1, 0, out totalCount);
            ExportFile.Instance.ExportData(dt, gvw, this);
        }
    }
}